/* Copyright 2008 Bas van den Berg
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <string>

#include "yaffut.h"
#include "myassert.h"
#include "TestRoom.h"

#include "MudCreature.h"
#include "config.h"

using namespace std;
using namespace Chronos;


struct MudCreatureTest : public MudCreature {
public:
    MudCreatureTest()
        : MudCreature("creature", "", 100, 1, 20, 80, true) 
		, lastTarget(0)
		, otherMob("mob", "", 100, 1, 20, 80, false)
		, room("test")
    {
		minChatInterval = seconds(10);
		maxChatInterval = seconds(10);
		room.addObject(this);
	}
	~MudCreatureTest() {
		room.removeObject(this);
	}
    virtual void addTarget(MudMobile& target) {
		lastTarget = &target;
	}

	MudMobile* lastTarget;
	MudCreature otherMob;
	TestRoom room;
};


TEST(MudCreatureTest, testAggressive) {
	handleRoomEvent(otherMob, MUDMOBILE_ARRIVE);
	ASSERT_EQUAL(&otherMob, lastTarget);
}


TEST(MudCreatureTest, testDoEmoteWithOneMessage) {
	addChat("blabla", 1);	
	ASSERT_EQUAL(seconds(10), doEmote());
	room.ROOM_CHECKWRITTEN("blabla\n");
}


TEST(MudCreatureTest, testDoEmoteWithoutMessages) {
	ASSERT_EQUAL(0, doEmote());
}


TEST(MudCreatureTest, testDoEmoteInCombat) {
	inCombat = true;
	addChat("blabla", 1);	
	ASSERT_EQUAL(seconds(10), doEmote());
	room.ROOM_CHECKWRITTEN("");
}


